from repoze.what import predicates
from pydive.config.version import app_version
from pydive.model.version import DBVersion
from pydive.model import DBSession
"""The application's Globals object"""

class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """
    _db_version = None
    p = predicates
    def _get_db_version (self):
        if self._db_version is None:
            self._db_version=DBSession.query(DBVersion).first().version
        return self._db_version
    
    def _set_db_version(self,data):
        pass
    
    app_version = app_version
    db_version = property(_get_db_version,_set_db_version)
    
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """
        from turbomail.adapters import tm_pylons
        tm_pylons.start_extension()
        #self.db_version = DBSession.query(DBVersion).all()
        # DBVersion
